<template>
  <div class="hello">
    <h1>{{ name }}</h1>
    <h1 v-for="(item, index) in list.value" :key="index">{{ item }}</h1>
    <h1>{{ msg }}</h1>
    <h3>Installed CLI Plugins</h3>
    <button @click="addevent">添加mitt事件</button>
  </div>
</template>

<script>
import committer from "../utils/mitter";
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  inject: ["name", "list"], //选择需要注入的数据   跨组件通信
  methods: {
    addevent() {
      committer.emit("btnclick", { name: "xfy", age: 18 });
      committer.emit("childrenclick", { name: "wang", age: 19 });
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
